package com.lww.feature.test.generics;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * User: yian
 * Date: 2017/9/24
 */
public class wild<T> {

    @Test
    public void arrayGenerics() {
//        @SuppressWarnings("unchecked")
        Set<String>[] sets = new Set[5];
//        Set<String>[] sets = new Set<String>[5];
//        @SuppressWarnings("unchecked")
        ArrayList<String>[] lsa = new ArrayList[10]; // Not really allowed.
        Object o = lsa;
        Object[] oa = (Object[]) o;
        List<Integer> li = new ArrayList<Integer>();
        li.add(new Integer(3));
        oa[1] = li; // Unsound, but passes run time store check
        String s = lsa[1].get(0); // Run-time error: ClassCastException.

    }
}
